import request  from '@/utils/request'
import type {ResponseSkuData,SkuData,spuData,HasSpuResponseData,spuTradeMarkResponseData,BaseSaleAttrData,skuImageResponseData,SaleAttrResponseData} from './type'
enum API{
    //获取spu接口
    HASSPU_URL='/api/admin/product/spuCategroy/',
    //获取品牌接口
    SPUTRADEMARK_URL='/api/admin/product/spuCategroy/getBaseTradeMark/',
    //获取sku图片接口
    SKUIMAGE_URL='/api/admin/product/spuCategroy/getskuImage/',
    //获取某一个spu下全部的已有的销售属性接口地址
    SPUHASSALEATTR_URL='/api/admin/product/spuCategroy/getSpuSaleAttrList/',
    //获取全部的的销售属性接口地址
    BASESALEATTR_URL='/api/admin/product/spuCategroy/getbaseSaleAttr',
    //更新销售属性
    UPDATEATTR_URL='/api/admin/product/spuCategroy/updateSpuSaleAttr',
    //新增销售属性
    ADDATTR_URL='/api/admin/product/spuCategroy/addSpuSaleAttr',
    //添加一个新的SKU
    ADDSKU_URL='/api/admin/product/skuInfo/saveInfo',
    //获取对应spu下的sku列表
    FANDSKU_URL='/api/admin/product/skuInfo/findSku/',
    //删除对应SPU
    DELETESKU_URL='/api/admin/product/spuCategroy/deleteCreateSpu4/',

    
}
//获取spu接口方法
export const reqHasSpu=(pageNow:number,pageSize:number,categroy3Id:number|string)=>request.get<any,HasSpuResponseData>(API.HASSPU_URL+`${pageNow}/${pageSize}/${categroy3Id}`)
//获取品牌接口方法
export const reqSpuTradeMaek=(c3Id:number)=>request.get<any,spuTradeMarkResponseData>(API.SPUTRADEMARK_URL+c3Id)
//获取sku图片接口方法
export const reqSkuImage=(id:number)=>request.get<any,skuImageResponseData>(API.SKUIMAGE_URL+id)
//获取某一个已有的spu拥有多少个销售属性
export const reqSpuHasSaleAttr=(id:number)=>request.get<any,SaleAttrResponseData>(API.SPUHASSALEATTR_URL+id)
//获取全部的的销售属性
export const reqBaseSaleAttr=()=>request.get<any,BaseSaleAttrData>(API.BASESALEATTR_URL)
//更新或增加销售属性
export const AddOrUpdateSaleAttr=(SpuParmas:spuData)=>{
    if(SpuParmas.id){
        return request.post<any,any>(API.UPDATEATTR_URL,SpuParmas)
    }else{
        return request.post<any,any>(API.ADDATTR_URL,SpuParmas)
    }
}
//添加一个新的SKU的请求方法
export const reqAddSku=(data:SkuData)=>request.post<any,ResponseSkuData>(API.ADDSKU_URL,data)
//获取对应spu下的sku列表的方法 
export const reqFindSku=(spuId:number|string)=>request.get<any,ResponseSkuData>(API.FANDSKU_URL+spuId)
//删除对应SPU方法
export const reqDeleteSku=(spuId:number|string)=>request.delete<any,any>(API.DELETESKU_URL+spuId)


